package com.example.gsnd21study.exception;

import com.example.gsnd21study.utils.ResultCode;
import lombok.Getter;
import lombok.Setter;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * 自定义异常类
 */
@Getter
@Setter
public class ServiceException extends Exception {
    // 维护一个ResultCode对象
    private ResultCode resultCode;

    // 1.单参数string构造器
    public ServiceException(String msg) {
        super(msg);
    }

    // 2.提供成员变量的构造器
    public ServiceException(ResultCode resultCode) {
        super(resultCode.getCode() + " - " + resultCode.getMsg());
        this.resultCode = resultCode;
    }
}
